//
//  YCTextChannelCollectionHeader.m
//  ChannelChoose
//
//  Created by 唐可雄 on 2019/7/27.
//  Copyright © 2019 swustyc. All rights reserved.
//

#import "YCTextChannelCollectionHeader.h"

@implementation YCTextChannelCollectionHeader

#pragma mark - UIView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self configView];
    }
    return self;
}

#pragma mark - View Config

- (void)configView {
    self.translatesAutoresizingMaskIntoConstraints = NO;
    
    self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 1, 1)];
    self.titleLabel.textColor = [UIColor blackColor];
    self.titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
    [self addSubview:self.titleLabel];
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.titleLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self  attribute:NSLayoutAttributeTop multiplier:1 constant:0]];
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.titleLabel attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self  attribute:NSLayoutAttributeLeading multiplier:1 constant:15]];
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.titleLabel attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self  attribute:NSLayoutAttributeWidth multiplier:0.5 constant:-15]];
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.titleLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self  attribute:NSLayoutAttributeBottom multiplier:1 constant:0]];
    
    self.subtitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 1, 1)];
    self.subtitleLabel.textColor = [UIColor lightGrayColor];
    self.subtitleLabel.textAlignment = NSTextAlignmentRight;
    self.subtitleLabel.font = [UIFont systemFontOfSize:15];
    self.subtitleLabel.translatesAutoresizingMaskIntoConstraints = NO;
    [self addSubview:self.subtitleLabel];
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.subtitleLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self  attribute:NSLayoutAttributeTop multiplier:1 constant:0]];
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.subtitleLabel attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self  attribute:NSLayoutAttributeWidth multiplier:0.5 constant:-15]];
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.subtitleLabel attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:self  attribute:NSLayoutAttributeTrailing multiplier:1 constant:-15]];
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.subtitleLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self  attribute:NSLayoutAttributeBottom multiplier:1 constant:0]];
}

@end
